﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace GuiClient
{
    public partial class UserControlManHinhNhapMucTienMuonRut : UserControl
    {
        public UserControlManHinhNhapMucTienMuonRut()
        {
            InitializeComponent();
        }

        public delegate void Thoat();
        public event Thoat ThoatEvent;

        public delegate void XacNhanGiaoDich(Double money);
        public event XacNhanGiaoDich XacNhanGiaoDichEvent;


        private void buttonThoat_Click(object sender, EventArgs e)
        {
            if (ThoatEvent != null)
            {
                ThoatEvent();
            }
        }

        private void buttonXacNhanGiaoDich_Click(object sender, EventArgs e)
        {            
            bool chuoiHopLe = true;
            Double money=0;
            try
            {
                money = Convert.ToDouble(this.textBoxSoTien.Text);
                if (money % 50000 != 0 || money<=0)
                {
                    chuoiHopLe = false;
                }
            }
            catch (Exception ex)
            {
                chuoiHopLe = false;
            }
            if (chuoiHopLe)
            {
                if (XacNhanGiaoDichEvent != null)
                {
                    XacNhanGiaoDichEvent(money);
                }
            }
            else
            {
                MessageBox.Show("Bạn nhập không hợp lệ !");
            }            
        }

        public void ResetGui()
        {
            this.textBoxSoTien.Text = "";
        }

        private void UserControlManHinhNhapMucTienMuonRut_Load(object sender, EventArgs e)
        {

        }
    }
}
